﻿using System;

namespace xycn.IDataCache
{
    /// <summary>
    /// 数据缓存接口
    /// </summary>
    public interface IDataCache
    {
        /// <summary>
        /// 获取缓存对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T GetCache<T>(string key);

        /// <summary>
        /// 获取缓存数据
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        dynamic GetCache(string key);

        /// <summary>
        /// 删除一个缓存
        /// </summary>
        /// <param name="key"></param>
        void DelCache(string key);

        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="key">缓存Key</param>
        /// <param name="value">缓存值</param>
        /// <returns></returns>
        bool SetCache(string key, object value);

        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="key">缓存Key</param>
        /// <param name="value">缓存值</param>
        /// <param name="minutes">过期时间单位 分钟</param>
        /// <returns></returns>
        bool SetCache(string key, dynamic value, int minutes);
    }
}
